package com.xielaoban.his1.common;

//封装通用返回对象
public class ServerResponse<T> {
    //状态码
    private int status;
    //返回信息“xxx成功”
    private String msg;
    //返回数据
    private T data;

    public int getStatus() {
        return status;
    }

    public String getMsg() {
        return msg;
    }

    public T getData() {
        return data;
    }

    //添加删除专用，比如{1，“添加成功”}
    private ServerResponse(int status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    //用于有数据返回的业务
    private ServerResponse(int status, String msg, T data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    //返回不带有数据的通用返回对象
    public static<T> ServerResponse<T> createBySuccess(){
        return new ServerResponse<T>(0,"success");
    }

    //返回带有数据的通用返回对象
    public static<T> ServerResponse<T> createBySuccess(T data){
        return new ServerResponse<T>(0,"success",data);
    }
}
